import { PageDateSelect } from '@/types/pages/enum';
import axios from 'axios';
import { ITransportList, ILogistics, ITotalTransport, ILogisticsQuantity } from '@/types/pages/logistics/interface';
import Mock from 'mockjs'
import { IDateLineChart, IDatePieChart } from '@/types/echart';

export const getTotalTransportData: (type: PageDateSelect, date?: Date) => Promise<ITotalTransport> = function (type: PageDateSelect, date?: Date) {
    return new Promise((res, rej) => {
        let data = {
            totalTransport: { unit: '万元', num: Mock.mock('@integer(50000, 150000)') },
            tarnTransport: { unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '3%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'},
            carTransport: { unit: '万元', num: Mock.mock('@integer(10000, 50000)'), saleRate: '5%', 'upDownStatus': Mock.mock('@boolean') ,comparisonText:'比去年'}
        }
        res(data);
    })

}

export const getTransportList: (type: PageDateSelect, date?: Date) => Promise<ITransportList> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        let data =Mock.mock({name:'陕西地区-运输情况', "list|1-10": [
            {name:Mock.mock('@string("upper", 5)'),toAmount:Mock.mock('@integer(60, 100)'),sendAmonut:Mock.mock('@integer(60, 100)'),storeAmount:Mock.mock('@integer(60, 100)')}
          ]})
        res(data);
    })

}

export const getPieLeftChart: (type: PageDateSelect, date?: Date) => Promise<IDatePieChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset:IDatePieChart={title:'运输方式（吨）',dataset:{dimensions:['名称','重量'],'source':[{'名称':'聚酯级'+Mock.Random.cname(),'重量|1-100':100,},{'名称':'聚酯级'+Mock.Random.cname(),'重量|1-100':100,},{'名称':'聚酯级'+Mock.Random.cname(),'重量|1-100':100,}]}}
        res(Mock.mock(dataset));

    })
}
export const getPieRightChart: (type: PageDateSelect, date?: Date) => Promise<IDatePieChart> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {
        const dataset:IDatePieChart={title:'运输结构（吨）',dataset:{dimensions:['名称','重量'],'source':[{'名称':'聚酯级'+Mock.Random.cname(),'重量|1-100':100,},{'名称':'聚酯级'+Mock.Random.cname(),'重量|1-100':100,},{'名称':'聚酯级'+Mock.Random.cname(),'重量|1-100':100,}]}}
        res(Mock.mock(dataset));
    })
}

export const getLogisticsQuantity: (type: PageDateSelect, date?: Date) => Promise<Array<ILogisticsQuantity>> = function (type: PageDateSelect, date) {
    return new Promise((res, rej) => {

        const data = [{title:'发货量',unit:'吨',num:'483'},{title:'发运量',unit:'吨',num:'398'},{title:'库存量',unit:'吨',num:'183'}]

        res(data);
    })
}

export const getMapChinaChart:(ype:PageDateSelect,date?:Date)=>Promise<IDateLineChart>=function(type:PageDateSelect,date){
  return new Promise((res,rej)=>{
    const a=()=>(Math.random()*2000).toFixed(2)
    const dataset:IDateLineChart={title:'',dataset:{dimensions:['地区','数值'],
    source:[{'地区':'北京','数值':a()},
    {'地区':'上海','数值':a()},
    {'地区':'湖北','数值':a()},
    {'地区':'河北','数值':a()},
    {'地区':'新疆','数值':a()},
    {'地区':'甘肃','数值':a()},
    {'地区':'内蒙古','数值':a()},
    {'地区':'黑龙江','数值':a()},
    {'地区':'辽宁','数值':a()},
    {'地区':'陕西','数值':a()},
    {'地区':'山西','数值':a()},
    {'地区':'湖南','数值':a()},
    {'地区':'广西','数值':a()},
    {'地区':'江西','数值':a()},
    {'地区':'福建','数值':a()},
    {'地区':'浙江','数值':a()},
    {'地区':'广东','数值':a()},
    {'地区':'青海','数值':a()},
    {'地区':'吉林','数值':a()},
    {'地区':'海南','数值':a()},
    {'地区':'桂林','数值':a()},
    {'地区':'河南','数值':a()},
    {'地区':'天津','数值':a()},
    {'地区':'江苏','数值':a()},
    {'地区':'山东','数值':a()},
    {'地区':'四川','数值':a()},
    {'地区':'西藏','数值':a()},
  ]}}
    res(Mock.mock(dataset));

  })
}
